/*
 * HubSoftware.java
 *
 * Created on 2 de Junho de 2006, 19:39
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package libjdc.dc.client;

import java.util.Iterator;
import java.util.LinkedList;

/**
 *
 * @author Daniel Botelho
 */
public class HubClient {
    
    private boolean dcPlusPlusExtensions = true;
   
    private static LinkedList<HubClient> clienteList = new LinkedList<HubClient>();
    
    public static LinkedList<HubClient> getAllClients(){
        return clienteList;
    }
    
    public static void addHubClient(int software_id, String software_name,String software_homepage,String software_img,String parser_regex){
        clienteList.add(new HubClient(software_id,software_name,software_homepage,software_img,parser_regex));
    }
    
    private int software_id;
    private String software_name;
    private String software_homepage;
    private String software_img;
    private String parser_regex;
    
    /** Creates a new instance of HubSoftware */
    private HubClient(int software_id, String software_name,String software_homepage,String software_img,String parser_regex) {
        this.setSoftware_id(software_id);
        this.setSoftware_name(software_name);
        this.setSoftware_homepage(software_homepage);
        this.setSoftware_img(software_img);
        this.setParser_regex(parser_regex);
    }
    
    public static HubClient getHubClient(String lock) throws UnsupportedHubClientException{
        HubClient hubSoft = null;
        Iterator<HubClient> it = clienteList.iterator();
        while(it.hasNext()){
            hubSoft = it.next();
            //Sniffer.out.println(hubSoft);
            if(hubSoft.getParser_regex()!= null)
                if( (lock.toLowerCase().indexOf(hubSoft.getParser_regex().toLowerCase())) > 0)
                    return hubSoft;
        }
        throw new UnsupportedHubClientException();
    }

    public String toString() {
        return software_id+", "+software_name+", "+software_homepage+", "+software_img+", "+parser_regex;
    }

    public int getSoftware_id() {
        return software_id;
    }

    public void setSoftware_id(int software_id) {
        this.software_id = software_id;
    }

    public String getSoftware_name() {
        return software_name;
    }

    public void setSoftware_name(String software_name) {
        this.software_name = software_name;
    }

    public String getSoftware_homepage() {
        return software_homepage;
    }

    public void setSoftware_homepage(String software_homepage) {
        this.software_homepage = software_homepage;
    }

    public String getSoftware_img() {
        return software_img;
    }

    public void setSoftware_img(String software_img) {
        this.software_img = software_img;
    }

    public String getParser_regex() {
        return parser_regex;
    }

    public void setParser_regex(String parser_regex) {
        this.parser_regex = parser_regex;
    }

    public boolean isDcPlusPlusExtensions() {
        return dcPlusPlusExtensions;
    }

    public void setDcPlusPlusExtensions(boolean dcPlusPlusExtensions) {
        this.dcPlusPlusExtensions = dcPlusPlusExtensions;
    }
    
}
